package com.briup.estore.web.servlet;

import com.briup.estore.common.result.Result;
import com.briup.estore.common.utils.JsonUtils;
import com.briup.estore.service.ShopCarService;
import com.briup.estore.service.impl.ShopCarServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author briup-adam
 * @Date 2023/8/4 下午4:47
 * @Description  添加商品到购物车
 **/
@WebServlet("/shopCar/add")
public class ShopCarAddServlet extends  BaseServlet {
    private ShopCarService shopCarService=new ShopCarServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String userId = (String) req.getAttribute("userId");
        String bookId = req.getParameter("id");
        shopCarService.add(Integer.parseInt(userId),Integer.parseInt(bookId));
        writeData(resp, Result.success());
    }
}
